#include "charts.h"
#include "ui_charts.h"

// 静态成员变量初始化
charts* charts::instance = nullptr;
QMutex charts::mutex;

charts::charts(QWidget* parent) :
    QWidget(parent),
    ui(new Ui::charts)
{
    ui->setupUi(this);

    // 初始化按钮
    widgetButton = ui->widget->getControlButton();
    widget2Button = ui->widget_2->getControlButton();
    widget3Button = ui->widget_3->getControlButton();
    widget4Button = ui->widget_4->getControlButton();
    widget5Button = ui->widget_5->getControlButton();
    widget6Button = ui->widget_6->getControlButton();
}

charts::~charts()
{
    delete ui;
}

charts* charts::getInstance(QWidget* parent)
{
    // 使用线程安全的单例模式
    if (!instance) {
        QMutexLocker locker(&mutex); // 锁住，确保线程安全
        if (!instance) {
            instance = new charts(parent);
        }
    }
    return instance;
}


